package edu.filefind.thread;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class FileFinderThread {
	
	public static void main(String[] args){
		
		List<FileFinder> runningThread = new ArrayList<FileFinder>();
		
		File[] rootFiles = File.listRoots();
		
		Scanner sca = new Scanner(System.in);
		System.out.println("Please input the suffix to search:");
		String suffix = sca.next();
		
		FileFinder ffd = null;
		for(int i=0;i<rootFiles.length;i++){
			File temp = rootFiles[i];
			String rootName = temp.getAbsolutePath();
			System.out.println("search " + rootName +"thread start!");
			
			ffd = new FileFinder(rootName,suffix);
			new Thread(ffd).start();
			runningThread.add(ffd);
		}
		
		new Thread(new MonitorThread(runningThread)).start();
				
	}

}
